package com.qch.rocket.demo.producer;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;

/**
 * @Author qch
 * @Date 2021/6/9
 */
public class Myproducer {
    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("producer_06_grp_01");
        producer.setNamesrvAddr("192.168.142.134:9876");
        producer.start();
        Message message = new Message("tp_demo_06", "hello qch".getBytes());
        SendResult result = producer.send(message, new MessageQueue("tp_demo_06", "node5.qch.com", 5));
        System.out.println(result);
        producer.shutdown();


    }
}
